import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { SearchItemType, type SearchItemConfig } from '@/types/component/search'
import type { Dept } from '@/types/api/system/dept'

/**
 * 使用搜索表单配置项
 * @param deptTree 部门树数据
 * @returns 搜索表单配置项
 */
export const useSearchItems = (deptTree: Dept[]) => {
  const { t } = useI18n()
  
  // 表单项配置
  return computed<SearchItemConfig[]>(() => [
    {
      field: 'keyword',
      label: t('user.keyword'),
      type: SearchItemType.INPUT,
      placeholder: t('user.searchKeywordPlaceholder')
    },
    {
      field: 'deptId',
      label: t('user.dept'),
      type: SearchItemType.TREE_SELECT,
      placeholder: t('user.selectDeptPlaceholder'),
      treeData: deptTree,
      fieldNames: { label: 'name', value: 'id', children: 'children' },
      treeDefaultExpandAll: true
    },
    {
      field: 'status',
      label: t('user.status'),
      type: SearchItemType.SELECT,
      placeholder: t('user.selectStatusPlaceholder'),
      options: [
        { value: 1, label: t('user.enabled') },
        { value: 0, label: t('user.disabled') }
      ]
    },
    {
      field: 'dateRange',
      label: t('common.dateRange'),
      type: SearchItemType.RANGE_PICKER,
      placeholder: [t('user.startDate'), t('user.endDate')]
    }
  ])
} 